Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
is-plain-object
Advanced tools
Return `true` if the given `value` is an object created by the `Object` constructor.
The is-plain-object package is a simple utility that checks if an object is a plain object, that is, an object created by the Object constructor or one with a null prototype.
Check if an object is a plain object
This feature allows you to verify if a given object is a plain object. It returns true for objects created by the Object constructor or with a null prototype and false for objects created by other constructors.
const isPlainObject = require('is-plain-object');
const obj = { x: 1, y: 2 };
console.log(isPlainObject(obj)); // true
const notPlain = Object.create(null);
console.log(isPlainObject(notPlain)); // true
function Test() { this.a = 1; }
console.log(isPlainObject(new Test())); // false
This package is a part of the Lodash library specifically for checking if a value is a plain object. It is similar to is-plain-object but comes from a well-known utility library, which might be preferable for projects already using Lodash.
Isobject checks if a value is an object and not null, but it does not check if the object is plain. It is less strict compared to is-plain-object, which specifically checks for plain objects.
Return
true
if the givenvalue
is an object created by theObject
constructor.
npm i is-plain-object --save
npm test
var isPlainObject = require('is-plain-object');
isPlainObject(1);
//=> false
isPlainObject(['foo', 'bar']);
//=> false
isPlainObject([]);
//=> false
isPlainObject(new Foo);
//=> false
isPlainObject(null);
//=> false
isPlainObject(Object.create(null));
//=> false
isPlainObject(Object.create({}));
//=> true
isPlainObject({foo: 'bar'});
//=> true
isPlainObject({});
//=> true
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on September 21, 2014.
FAQs
Returns true if an object was created by the `Object` constructor, or Object.create(null).
The npm package is-plain-object receives a total of 45,730,855 weekly downloads. As such, is-plain-object popularity was classified as popular.
We found that is-plain-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.